#include "app_pool.h"
#include <pthread.h>
#include <unistd.h>
#include <assert.h>

static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

void test_task(void *arg)
{
    int *a = arg;
    pthread_mutex_lock(&lock);
    (*a) += 1;
    pthread_mutex_unlock(&lock);
}

int main(void)
{
    app_pool_init(5);
    int a = 0;

    for (int i = 0; i < 100; i++)
    {
        app_pool_submit(test_task, &a);
    }

    sleep(5);
    assert(a == 100);

    app_pool_deinit();
    return 0;
}
